<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../header.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx }/webuploader/webuploader.css">
<link rel="stylesheet" type="text/css" href="${ctx }/webuploader/style.css">
<link rel="stylesheet" type="text/css" href="${ctx }/bootstrap/css/bootstrap-datetimepicker.css">
<link rel="stylesheet" type="text/css" href="${ctx }/pagejs/pagination.css" >
<!--引入JS-->
<script type="text/javascript" src="${ctx }/webuploader/webuploader.js"></script>
<script type="text/javascript" charset="utf-8"src='${ctx }/ueditor/ueditor.config.js'></script>
<script type="text/javascript" charset="utf-8" src="${ctx }/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctx }/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctx }/bootstrap/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctx }/views/topic/addtopic.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctx }/bootstrap/js/bootstrap-datetimepicker.fr.js"></script>
<script type="text/javascript" src="${ctx }/pagejs/pagination.js"></script>
<style>
	.topic_parent{
		position: relative;
	}
	.before{
		width:400px;
		height:120px;
		position: absolute;
		top:0;
		right:40px;
	}
	
	.before img{
		width:100%;
		height:100%;
	}
	
</style>
<div class="container">
<div class="panel panel-info">
    <ol class="breadcrumb">
  <li><a href="#">话题</a></li>
  <li><a href="#" class="active">修改话题</a></li>
</ol>
   <div class="panel-body topic_parent">
      	<form id="defaultForm" class="form-horizontal" role="form" action="${ctx }/topic/addtopic" method="post">
      					
      					<%-- <div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">显示时间:</label>
						<div class="col-sm-5">
							<input type="text" class="form-control" name="showdate" readonly 
							 id="datetimepicker" placeholder="请选择日期" data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd"
							 value="${topic.dateStr }">
						</div>
						<div>
						</div>
						</div> --%>
					<div class="form-group">
						 <!--用来存放item-->
						<label for="firstname" class="col-sm-2 control-label">话题封面</label>
						<div class="col-sm-10">
						    <div id="fileList" class="uploader-list"></div>
						   <div id="filePicker">选择图片</div>
						</div>
						<input type="hidden" name="imgKey" value="${topic.imgKey }" id="imgKey"/>
					 </div>
					 
					<div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">品牌:</label>
						<div class="col-sm-5">
							<select class="form-control" name="brand">
							<option value="">--品牌列表--</option>
								<c:forEach var="bean" items="${brand }">
										<option value="${bean.id }" <c:if test="${topic.brandid == bean.id }">selected="selected"</c:if>>${bean.name }</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">关联商品:</label>
						<div class="col-sm-1">
						  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">选择商品</button>
						</div>
						<div class="col-sm-7">
						<%-- <input type="text" class="form-control" readonly="readonly" name="productName" value="${product.manufacture }" placeholder="请选择商品">
						<input type="hidden" class="form-control" name="productId" value="${product.productId}"> --%>
						<input type="hidden" name="id" value="${topic.id }">
						</div>
					</div>
					<c:forEach items="${ps }" var="st">
					<div class="form-group">
					<label for="firstname" class="col-sm-2 control-label"></label>
					<div class="col-sm-6">
					<input type="text" class="form-control" readonly="readonly" value="${st }" name="productName"></div>
					<div class="col-sm-1">
					<button type="button" class="btn btn-danger" onclick='deleteData(this)'>删 除</button>
					</div>
					</div>
					</c:forEach>
					<div class="form-group tmp">
					</div>
					<div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">标题:</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="title" id="title"
								placeholder="请输入标题" value="${topic.title }">
						</div>
					</div>
					<div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">内容:</label>
						<div class="col-sm-10">
							<script id="container" name="content" type="text/plain" style="height: 500px;">
							</script>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-info">发布</button>
							<!-- <button type="button" class="btn btn-default" id="back">返 回</button> -->
						</div>
					</div>
				</form>
		<div class="before">
			<img src="${topic.imgUrl }" class="img-rounded">
		</div>
   </div>
</div>
</div>
<%@ include file="selectproduct.jsp" %>
<!-- 实例化编辑器 -->
	<script type="text/javascript">
	
	$('#datetimepicker').datetimepicker({
		language:  'fr',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0
	});
	
	
	
		var editor = UE.getEditor('container');
		//判断ueditor 编辑器是否创建成功
        editor.addListener("ready", function () {
        editor.execCommand('insertHtml', '${topic.content}');
        // editor准备好之后才可以使用
        //editor.setContent('${topic.content}');
 
        });
		UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
		UE.Editor.prototype.getActionUrl = function(action) {
		    if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
		        //return 'http://a.b.com/upload.php';
		        return ctx + "/ueditor/imageupload";
		    } else if (action == 'uploadvideo') {
		        return 'http://a.b.com/video.php';
		    } else {
		        return this._bkGetActionUrl.call(this, action);
		    }
		}
	
		
	</script>